<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="../scripts/boot.js"></script>
<script type="text/javascript"
	src="../scripts/fileupload/swfupload/swfupload.js"></script>
<link href="../scripts/miniui/themes/blue/skin.css" rel="stylesheet"
	type="text/css" />
<title>My JSP 'index.jsp' starting page</title>


</head>

<body>
	<h1>测试脚本信息</h1>

	<div style="width:100%;">
		<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
			<table style="width:100%;">
				<tr>
					<td style="width:100%;"><a class="mini-button"
						iconCls="icon-add" onclick="add()">增加</a> <a class="mini-button"
						iconCls="icon-remove" onclick="remove()">删除</a> <a class="mini-button"
						iconCls="icon-undo" onclick="execute()">执行所有</a></td>
					<td style="white-space:nowrap;"><input id="fileupload1"
						class="mini-fileupload" name="filename" limitType="*.jmx"
						flashUrl="../scripts/fileupload/swfupload/swfupload.swf" uploadUrl="<%=basePath %>/UploadwithServlet"
						onuploadsuccess="onUploadSuccess" onuploaderror="onUploadError"
						onfileselect="onFileSelect" /> <a class="mini-button"
						value="上传" onclick="startUpload()" >上传</a></td>
				</tr>
			</table>
		</div>
	</div>
	
	<div id="datagrid1" class="mini-datagrid"
		style="width:100%;height:70%;" allowResize="true"
		url="<%=basePath %>/ValidataXML" showPager="false"
		multiSelect="true">
		<div property="columns">
			<div type="indexcolumn"></div>       
			<div type="checkcolumn"></div>
			<div field="jmxName" width="50" headerAlign="center"
				allowSort="true">脚本名称</div>
			<div field="result" width="50" headerAlign="center" renderer="onGenderRenderer"
				allowSort="true">校验结果</div>
				<div field="info" width="50" headerAlign="center"
				allowSort="true">校验信息</div>
			
                    <div field="jmxInfo.jmxTestInfo" width="300">脚本信息</div>
                  
                </div>
          
		
	</div>
	<h1>测试结果信息</h1>
<div id="datagrid2" class="mini-datagrid"
		style="width:100%;height:70%;" allowResize="true"
		url="<%=basePath %>/AnalysisJtl" showPager="false"
		multiSelect="true">
		<div property="columns">
			<div type="indexcolumn"></div>       
			<div type="checkcolumn"></div>
			<div field="t" width="50" headerAlign="center"
				allowSort="true">响应时间</div>
			<div field="result" width="50" headerAlign="center" renderer="onGenderRenderer"
				allowSort="true">测试结果</div>
				<div field="tn" width="50" headerAlign="center"
				allowSort="true">线程组信息</div>
			
                    <div field="jtlInfo" width="300">详细信息</div>
                  
                </div>
          
		
	</div>
	<div style="width:100%;">
		<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
			<table style="width:100%;">
				<tr>
					<td style="width:100%;">
					 <a class="mini-button"iconCls="icon-undo" onclick="piechart()">查看饼图</a> 
					 <a class="mini-button"iconCls="icon-undo" onclick="barchart()">查看柱状图</a></td>
					
				</tr>
			</table>
		</div>
	</div>
	<script type="text/javascript">
    var Genders = [{ id: true, text: "true" }, { id: false, text: "false"}];

        mini.parse();

        var grid = mini.get("datagrid1");
        var grid2 = mini.get("datagrid2");
        grid.load();
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
        function add() {
mini.open({
    url: bootPATH + "../page/newJmx.jsp",
    title: "新增JMX", width: 800, height: 400,
    onload: function () {
        var iframe = this.getIFrameEl();
        var data = { action: "new"};
        iframe.contentWindow.SetData(data);
    },
    ondestroy: function (action) {

        grid.reload();
    }
});
        }
        function execute(){
        	$.ajax({
                url: "<%=basePath %>/Ant",
                success: function (text) {
                    grid2.reload();
                },
                error: function () {
                }
            });
        }
        function barchart(){
        	mini.open({
        	    url: "<%=basePath %>/BarChart",
        	    title: "查看柱状图", width: 800, height: 400,
        	    onload: function () {
        	        var iframe = this.getIFrameEl();
        	        var data = { action: "new"};
        	        iframe.contentWindow.SetData(data);
        	    },
        	    ondestroy: function (action) {

        	        grid.reload();
        	    }
        	});
        }
        function piechart(){
        	mini.open({
        	    url: "<%=basePath %>/PieChart",
        	    title: "查看饼图", width: 800, height: 400,
        	    onload: function () {
        	        var iframe = this.getIFrameEl();
        	        var data = { action: "new"};
        	        iframe.contentWindow.SetData(data);
        	    },
        	    ondestroy: function (action) {

        	        grid.reload();
        	    }
        	});
        	
        	
        }
        function remove() {
            
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                if (confirm("确定删除选中记录？")) {
                    var ids = [];
                    for (var i = 0, l = rows.length; i < l; i++) {
                        var r = rows[i];
                        ids.push(r.jmxName);
                    }
                    var id = ids.join(',');
                    grid.loading("操作中，请稍后......");
                    $.ajax({
                        url: "<%=basePath %>/DeleteJmx",
                        type: 'post',
                        data: { data: id },
                        success: function (text) {
                            grid.reload();
                        },
                        error: function () {
                        }
                    });
                }
            } else {
                alert("请选中一条记录");
            }
        }

        function onFileSelect(e) {
            //alert("选择文件");
        }
        function onUploadSuccess(e) {

            alert("上传成功：" + e.serverData);

            this.setText("");
            grid.load();
        }
        function onUploadError(e) {
            
        }

        function startUpload() {
        	
            var fileupload = mini.get("fileupload1");

            fileupload.startUpload();
        }






    </script>


</body>
</html>
